home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7346 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: surfnet.nl!sun4nl!xs4all!usenet
  2. From: Ronald Werring <ronaldw@xs4all.nl>
  3. Newsgroups: comp.lang.c++
  4. Subject: Q: implementing streambuf::underflow() method
  5. Date: 22 Feb 1996 20:21:42 GMT
  6. Organization: XS4ALL, networking for the masses
  7. Message-ID: <4gij8m$pi7@news.xs4all.nl>
  8. NNTP-Posting-Host: asd06-14.dial.xs4all.nl
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  13.  
  14. I want to make a subclass of the streambuf class to
  15. implement a different buffering strategy for an istream.
  16. I use Visual-C++ (1.5 and 4.0).
  17.  
  18. My question: "When is underflow() called? Only when
  19.               the buffer is empty or for every character?"
  20.  
  21. (part of) my source:
  22. int MyStreamBuf::underflow()
  23. {
  24.     // is this line necessary?
  25.     if (in_avail()) return *gptr();
  26.  
  27.     // setting new get pointers with setg
  28.     // when buffer is empty
  29.     char* gptr = m_text[m_regel]; // get buffer from stringarray
  30.     if (gptr == 0) return EOF;
  31.     int len = strlen(gptr);
  32.     setg(gptr, gptr, gptr+len);
  33.     m_regel++;
  34.  
  35.     // return first of new buffer
  36.     return *gptr;
  37. }
  38.  
  39. Anybody experienced?
  40.  
  41. Ronald Werring
  42.  
  43.  
  44.  
  45.